package com.seed.launcher.listener.bean;

import android.net.wifi.WifiManager;

import androidx.annotation.Keep;

import java.util.Objects;

/**
 * @author xct
 * create on: 2022/8/31 11:14
 */
@Keep
public class WifiInfo {
    //接入点地址
    public String BSSID;
    //网络名称
    public String SSID;
    //介绍接入点支持的身份验证，密钥管理和加密方案
    public String capabilities;
    //客户端与接入点通信的信道的主要20 MHz频率（以MHz为单位)
    public int frequency;
    //以dBm为单位的检测信号电平，也称为RSSI
    public int level;
    // 这个结果最后一次出现时的时间戳（以微秒为单位）
    public long timestamp;


    public int calculateSignalLevel(int numLevels){
        return WifiManager.calculateSignalLevel(level,numLevels);
    }

    @Override
    public String toString() {
        return "WifiInfo{" +
                "BSSID='" + BSSID + '\'' +
                ", SSID='" + SSID + '\'' +
                ", capabilities='" + capabilities + '\'' +
                ", frequency=" + frequency +
                ", level=" + level +
                ", timestamp=" + timestamp +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof WifiInfo)) return false;
        WifiInfo wifiInfo = (WifiInfo) o;
        return frequency == wifiInfo.frequency
                && level == wifiInfo.level
                && BSSID.equals(wifiInfo.BSSID)
                && SSID.equals(wifiInfo.SSID)
                && capabilities.equals(wifiInfo.capabilities);
    }

    @Override
    public int hashCode() {
        return Objects.hash(BSSID, SSID, capabilities, frequency, level);
    }
}
